home *** CD-ROM | disk | FTP | other *** search
/ Aminet 18 / aminetcdnumber181997.iso / Aminet / dev / amos / AMOSList_0197.lzh / AMOSLIST / 000137_amos-request@svcs1.digex.net_Sat Jan 25 08:45:44 1997.msg < prev    next >
Internet Message Format  |  1997-02-02  |  2KB

  1. Received: from svcs1.digex.net (svcs1.digex.net [204.91.197.224])
  2.     by mail2.access.digex.net (8.8.5/8.8.5) with ESMTP id IAA06453
  3.     for <mcox@access.digex.net>; Sat, 25 Jan 1997 08:45:42 -0500 (EST)
  4. Received: (from daemon@localhost)
  5.     by svcs1.digex.net (8.8.5/8.8.5) id IAA15550
  6.     for amos-out; Sat, 25 Jan 1997 08:00:46 -0500 (EST)
  7. Received: from mail1.access.digex.net (mail1.access.digex.net [205.197.247.2])
  8.     by svcs1.digex.net (8.8.5/8.8.5) with ESMTP id IAA15547
  9.     for <amos-list@svcs1.digex.net>; Sat, 25 Jan 1997 08:00:45 -0500 (EST)
  10. Received: from red.paston.co.uk (red.paston.co.uk [194.129.188.3])
  11.     by mail1.access.digex.net (8.8.5/8.8.5) with ESMTP id IAA07179
  12.     for <amos-list@access.digex.net>; Sat, 25 Jan 1997 08:00:44 -0500 (EST)
  13. Received: from paston.co.uk ([194.129.188.201]) by red.paston.co.uk with SMTP id <843245-28210>; Sat, 25 Jan 1997 12:59:27 -0000
  14. From: Ben Wyatt <bwyatt@paston.co.uk>
  15. To: amos-list@access.digex.net
  16. Date:     Sat, 25 Jan 1997 00:21:56 -0000
  17. Message-ID: <yam6964.2840.4022152@194.129.188.3>
  18. In-Reply-To: <9f5_9701240826@setnet.co.yu>
  19. X-Mailer: YAM 1.3.4 [020] - Amiga Mailer by Marcel Beck
  20. Subject: Re: goto
  21. MIME-Version: 1.0
  22. Content-Type: text/plain
  23. Status: RO
  24. X-Status: 
  25.  
  26. On 24-Jan-97, Nikola Smolenski sat on a keyboard and produced this mess:
  27.  
  28. >  gs> Do
  29. >  gs> Goto Rnd(4)
  30. >  gs> 0
  31. > <bla>
  32. >  gs> 1
  33. > <bla>
  34. >  gs> 2
  35. > <bla>
  36. >  gs> 3
  37. > <bla>
  38. >  gs> 4
  39. > <bla>
  40. >  gs> Loop
  41.  
  42. >  gs> How can I get the program to go to each label
  43. >  gs> only once?  (randomly)
  44.  
  45. > I think this is the easiest:
  46. > dim a(n)
  47. > for i=1 to n
  48. > a(i)=i
  49. > next
  50. > for i=1 to n
  51. > r=rnd(n)+1
  52. > goto r
  53. > a(r)=a(n)
  54. > dec n
  55. > next
  56.  
  57. I can't follow the logic of that program, but this program will do what was
  58. originally requested:
  59.  
  60. Dim a(4)
  61.  
  62. ' Store the label numbers in an array
  63. For n=0 To 4
  64. a(n)=n
  65. Next n
  66.  
  67. ' Shuffle the array about, 25 times
  68. For time=1 To 25
  69. Swap a(Rnd(4)),a(Rnd(4))
  70. Next time
  71.  
  72. ' Go to each label in a random order
  73. For n=0 To 4
  74. Gosub a(n)
  75. Next n
  76.  
  77. 0 ... Return
  78. 1 ... Return
  79. 2 ... Return
  80. 3 ... Return
  81. 4 ... Return
  82.  
  83. Bye_______________________________
  84.   /                               \
  85.  / Ben Wyatt - bwyatt@paston.co.uk \
  86.  \            or b.wyatt@uea.ac.uk /
  87.   \_______________________________/ (c)1995-97 Very Interesting Signatures
  88.